<template lang="html">
<div class="app-version-page normal-table-page">
	<Card :dis-hover="true">
		<p slot="title">
			<Icon type="social-youtube"></Icon> APP首页视频管理
		</p>
		<div slot="extra">

			<!-- <Input v-model="searchKey" class="search-input" icon="search" placeholder="兑换码、兑换人或手机号" style="width: 300px" @keydown.native.enter="doSearch"></Input> -->
			<Button type="ghost" class="add-new-btn" v-if="searchKey" @click="clearSearch()">清空</Button>

			<Button type="ghost" class="add-new-btn" icon="plus" @click="showModal = true">新增</Button>
		</div>
		<Table :columns="appVersionTableColumns" :loading="pageLoading" ref="appVideoTable" border :data="appVersionList"></Table>

		<div class="page-ctrl" v-if="pageCount">
			<Page :total="pageCount" :current="pageNum" show-total show-elevator @on-change="changePage" :page-size="20">
			</Page>
		</div>
	</Card>
	<Modal :mask-closable="false" v-model="showModal" :title="selectVersion ? '编辑':'新增'" :loading="modalLoading" class-name="appversion-modal" @on-ok="clickOK()">
		<Form :model="appVersionForm" ref="appVersionForm" :rules="appVersionFormRules">
			<FormItem label="操作系统" prop="app_system">
				<RadioGroup v-model="appVersionForm.app_system" @on-change="selectAppSystemChange">
					<Radio label="IOS">
						<Icon type="social-apple" size="20" style="vertical-align: middle;margin-top:-1px"></Icon>
						<span>Apple</span>
					</Radio>
					<Radio label="ANDROID">
						<Icon type="social-android" size="20" style="vertical-align: middle;margin-top:-1px"></Icon>
						<span>Android</span>
					</Radio>
				</RadioGroup>
			</FormItem>
            <Upload type="drag" :action="postUrl.doUploadAppUrl" :data="uploadFileData" :show-upload-list="false" :before-upload="beforeUpload" :headers="{'Access-Control-Allow-Origin':'*'}" :on-success="uploadSuccess" :on-error="uploadError"
                :on-progress="uploadProgressFunc" :format="appVersionForm.app_system == 'IOS'?['ipa']:['apk']" :on-format-error="handleFormatError" class="upload-file">
            	<slot>
            		<Icon :type="appVersionForm.app_system == 'IOS'?'social-apple':'social-android'"  size="50" :color="fileUrl?(appVersionForm.app_system == 'IOS'?'':'#6ab344'):'rgba(0,0,0,.2)'"></Icon>
            		<div slot="tip" class="tip-text">{{fileUrl?bytesToSize(fileSize):'上传安装包'}}</div>
            		<transition name="fade">
            			<div class="progress" v-if="isUploading">
                            <span>
                                 {{uploadProgress || 0}}%
                            </span>
                        </div>
            		</transition>
            	</slot>
            </Upload>
            <FormItem label="APPID" prop="package" >
                <Input v-model="appVersionForm.package" placeholder="请输入APPID" :disabled="true"></Input>
            </FormItem>
            <FormItem label="版本号" prop="versioncode">
                <Input v-model="appVersionForm.versioncode" placeholder="请输入版本号"></Input>
            </FormItem>
            <FormItem label="版本名称" prop="versionname">
                <Input v-model="appVersionForm.versionname" placeholder="请输入版本名称"></Input>
            </FormItem>
            <FormItem label="发布时间" prop="releasetime" >
                <DatePicker v-model="appVersionForm.releasetime" :transfer="true" :placement="'top-start'" type="datetime" format="yyyy-MM-dd HH:mm:ss"  placeholder="选择日期" style="width: 200px"></DatePicker>
            </FormItem>
            <FormItem label="说明" prop="note">
                <Input v-model="appVersionForm.note" type="textarea" :autosize="{minRows: 2,maxRows: 5}" placeholder="请输入说明" ></Input>
            </FormItem>
		</Form>
	</Modal>
</div>
</template>

<script src="./app-version.js">
</script>

<style lang="scss" src="./app-version.scss">
</style>
